/********************************************************************************************/
/* Fullhan Technology (Shanghai) Co., Ltd.                                                  */
/* Fullhan Proprietary and Confidential                                                     */
/* Copyright (c) 2017 Fullhan Technology Group Limited and its affiliated companies         */
/********************************************************************************************/
#ifndef __DRV_CESA_IF_H__
#define __DRV_CESA_IF_H__



#include "drv_cesa_ioctl.h"
#include <crypto/scatterwalk.h>




//==========================AUXILIARY================================
typedef struct semaphore	os_sem_t;
typedef struct _FH_CESA_AUX_S {
	uint32_t keep_ades;
	os_sem_t sem_ades;
	os_sem_t sem_sha;
	os_sem_t sem_rsa;

	struct completion completion_ades;

	#define ADES_MAX_BLOCK		(1024*CONFIG_FH_CESA_AES_KBUFF_SIZE)
	void *ker_data_addr;
	uint32_t phy_data_addr;
	struct device *dev;
} FH_CESA_AUX_S;








void drv_cesa_aux_init(FH_CESA_AUX_S *p_aux);
void drv_cesa_aux_deinit(FH_CESA_AUX_S *p_aux);
uint32_t drv_cesa_ades_phy_data_addr(uint32_t session);
int32_t drv_cesa_ades_dma_sync_single_for_device(uint32_t session, uint32_t user_src_addr, uint32_t length);
int32_t drv_cesa_ades_dma_sync_single_for_cpu(uint32_t session, uint32_t user_dst_addr, uint32_t length);
int32_t drv_cesa_ades_dma_sync_single_for_device_sg(uint32_t session,
	struct scatterlist *sgl, uint32_t proc_len, uint32_t skip);
int32_t drv_cesa_ades_dma_sync_single_for_cpu_sg(uint32_t session,
	struct scatterlist *sgl, uint32_t proc_len, uint32_t skip);

int32_t drv_cesa_ades_create(uint32_t *p_session, void *p_priv);
int32_t drv_cesa_ades_destroy(uint32_t session);
int32_t drv_cesa_ades_config(uint32_t session, FH_CESA_ADES_CTRL_S *p_ctrl);
int32_t drv_cesa_ades_config_oper(uint32_t session,
					FH_CESA_ADES_OPER_MODE_E oper_mode);
int32_t drv_cesa_ades_process(uint32_t session, uint32_t phy_src_addr, uint32_t phy_dst_addr, uint32_t length);
int32_t drv_cesa_ades_process_ext(uint32_t session, uint32_t p_src_addr, uint32_t p_dst_addr, uint32_t length);
int32_t drv_cesa_ades_get_infor(uint32_t session, FH_CESA_ADES_CTRL_S *p_ctrl);
int32_t drv_cesa_ades_efuse_key(uint32_t session, FH_CESA_ADES_EFUSE_PARA_S *efuse_para);
int32_t drv_cesa_ades_addr_attr(uint32_t session,
					FH_CESA_ADES_ADDR_ATTR_E src_addr_attr,
					FH_CESA_ADES_ADDR_ATTR_E dst_addr_attr);
int32_t drv_cesa_ades_intr(void *cesa_aux);

int fh_ce_register_algs(struct device *dev);
void fh_ce_unregister_algs(struct device *dev);

#endif	/*__DRV_CESA_IF_H__*/

